home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / util / rexx / rmh.lha / RMH / Examples / gr.rexx < prev    next >
OS/2 REXX Batch file  |  2001-05-24  |  1KB  |  47 lines

  1. /*
  2. */
  3.  
  4. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  5. if ~open("STDERR","CONSOLE:","W") then stderr="STDOUT"
  6.  
  7. if ~ReadArgs("PATTERN/A,FILE/A/M,CASE/S,ALL/S") then do
  8.     call PrintFault()
  9.     exit
  10. end
  11.  
  12. pa=parm.0.value
  13. case=parm.2.flag
  14. if case then patt=ParsePattern(pa,"CASE")
  15. else patt=ParsePattern(pa)
  16. if patt="" then do
  17.     call SetIoErr(114)
  18.     call PrintFault()
  19.     exit
  20. end
  21. all=parm.3.flag
  22.  
  23. do m=0 to parm.1.mult-1
  24.     call DirWalk(parm.1.value.m)
  25. end
  26. exit
  27.  
  28. DirWalk: procedure expose patt case all
  29. parse arg file
  30.     do f=0 to expand("A",file)-1
  31.         file=a.f
  32.         if a.f.type="DIR" then do
  33.             if all then call DirWalk(AddPart(file,"#?"))
  34.             iterate
  35.         end
  36.         if ~open(in,file,"R") then iterate
  37.         match=0
  38.         do i=0 while ~eof(in) & match=0
  39.             l=readln(in)
  40.             if case then match=MatchPattern(patt,l,"CASE")
  41.             else match=MatchPattern(patt,l)
  42.         end
  43.         call close(in)
  44.         if match>0 then say file
  45.     end
  46.     return
  47.